import { request } from './base'

export interface ExamHistory {
	userId?: string | null
    startTime?: string | null
	endTime?: string | null
	score?: number | null
	[property: string]: any
}
//创建考试记录
export async function createLeveExam(user: ExamHistory): Promise<any> {
    const response = await request.post('/leveExam/create', {...user})
    return response.data
}

//获取考试记录(id)
export async function getLeveExamById(id: string): Promise<any> {
    const response = await request.get('/leveExam/getById', { params: { id } })
    return response.data
   
}

//获取所有考试记录
export async function getAllLeveExam(pageNum: number, pageSize: number): Promise<any> {
    const response = await request.get('/leveExam/exams', {
        params: {
            pageNum,
            pageSize
        }
    })
    return response.data.data.data
}

//获取考试记录(userId)
export async function getLeveExamByUserId(userId: number): Promise<ExamHistory[]> {
    const response = await request.get('/leveExam/getByUserId', { params: { userId } })
    return response.data
}

//删除考试记录
export async function deleteLeveExam(id: string): Promise<any> {
    const response = await request.delete('/leveExam/delete', { params: { id } })
    return response.data
}